package Thread;

/**
 * Created with IntelliJ IDEA.
 * Description: 多线程实现使用方法一：新创建一个新的类继承Thread类
 */
class MyThread extends Thread {
    @Override
    public void run() {
        while(true) {
            System.out.println("Thread!");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

public class ThreadDemo1 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new MyThread();
        thread.start();
        while(true) {
            System.out.println("world");
            Thread.sleep(1000);
        }
    }
}
